layui.config({
    base : "/dhjdglxt/modules/util/"//自定义加载的模块
}).use(['form','layer','jquery','layedit','laydate','laypage','table','commUtil','element','treetable'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : parent.layer,
        laypage = layui.laypage,
        layedit = layui.layedit,
        laydate = layui.laydate,
        $ = layui.jquery;
    var table = layui.table;
    var commUtil = layui.commUtil;
    var element = layui.element;
    var treetable = layui.treetable;//很重要
    
    
    $.ajax({
        type: "GET",
        url:basePath+'/service/jddtgzsz/jddtgzsz/getJksxglList',
        async:false,
        dataType: "json",
        success: function(data){
       	 	if(data.length > 0){
       	 		for(var i=0; i<data.length; i++ ){
       	 			$("#s_jksxId").append("<option value=\""+data[i].recId+"\">"+data[i].sxname+"</option>")
       	 		}
       	 	}
       	 	form.render("select");
        }
    });

  //监听工具条
    table.on('tool(modelInfo)', function(obj){
        var data = obj.data;
        if(obj.event === 'view'){
        	view(data)
        }else if(obj.event === 'remind'){
        	remind(data)
        }else if(obj.event === 'closeTx'){
        	closeTx(data)
        }
    });


    $(".onQuery").click(function(){
        onQuery();
    })

    //查询
    function onQuery(){
        var s_jksxId = $('#s_jksxId').val();
        var s_txtype = $('#s_txtype').val();
        var s_jcStatus = $('#s_jcStatus').val();
        var s_clStatus = $('#s_clStatus').val();
        //执行重载
        table.reload('modelInfo', {
            page: {
                curr: 1 //重新从第 1 页开始
            },
            where: {
            	s_jksxId: s_jksxId,
            	s_txtype: s_txtype,
            	s_clStatus:s_clStatus,
            	s_jcStatus:s_jcStatus
            }
        });
    }
    
    //查看
    function view(obj) {
	    var index = layui.layer.open({
	        title : "查看",
	        type : 2,
	        skin:'layui-layer-molv',
	        content : basePath+"/service/dtjktxlog/jddtdtjktxlog/"+obj.recId,
	        area: ['990px', '470px'],
	        offset: 't',
	        success : function(layero, index){
	            commUtil.resizeLayer(index,'470');
	        }
	    })
    }
    
    //人工提醒
    function remind(obj) {
        layer.confirm('您确定要人工提醒吗？',{icon:3, title:'提示信息'}, function(index){
            $.ajax({
                type: "POST",
                url: basePath + '/service/dtjktxlog/jddtdtjktxlog/remind/'+obj.recId,
                async: false,
                dataType: "json",
                success: function (data) {
                    layer.msg("操作成功！",{icon:1});
                    onQuery();
                }
            });
        });
    }
    
  //关闭提醒
    function closeTx(obj) {
        layer.confirm('您确定要关闭提醒吗？',{icon:3, title:'提示信息'}, function(index){
            $.ajax({
                type: "POST",
                url: basePath + '/service/dtjktxlog/jddtdtjktxlog/closeTx/'+obj.recId,
                async: false,
                dataType: "json",
                success: function (data) {
                    layer.msg("操作成功！",{icon:1});
                    onQuery();
                }
            });
        });
    }
})
function HTMLDecode(text) {
    var temp = document.createElement("div");
    temp.innerHTML = text;
    var output = temp.innerText || temp.textContent;
    temp = null;
    return output;
} 